@extends('layouts.admin')

@section('content')
<section id="main-content">
  <section class="wrapper">
      <!-- page start-->
      <div class="row">
          <div class="col-sm-12">
                      <section class="panel">
                          
                          <div class="panel-body">
                              <a href="{{ route('admin.wechat.menu.sysnc') }}" type="button" class="btn btn-info ">同步微信自定义菜单</a>
                              
                     
                          </div>
                      </section>
                  </div>
          <div class="col-lg-12">
              <section class="panel">

                <div class="panel panel-default">
                    <div class="panel-body">

                        <div class="pull-right">
                            <div class="btn-group mr10">
                                <a href="{{ route('admin.wechat.menu.create') }}" class="btn btn-white tooltips"
                                   data-toggle="tooltip" data-original-title="新增"><i
                                            class="glyphicon glyphicon-plus"></i></a>
                                
                            </div>
                        </div><!-- pull-right -->

                        <h5 class="subtitle mb5">自定义菜单</h5>
                        <div class="row">
                  <div class="col-sm-12">
                      <section class="panel">
                          <header class="panel-heading no-border">
                              
                          </header>
                          <table class="table table-bordered">
                              <thead>
                              <tr>
                                  <th>#</th>
                                  <th>名称</th>
                                  <!-- <th>上级</th> -->
                                  <th>类型</th>
                                  <th>Key</th>
                                  <th>Url</th>
                                  <th>排序</th>
                                  <th>操作</th>
                              </tr>
                              </thead>
                              <tbody>
                              @foreach ($menus as $menu)
                                   <tr>

                                      @if($menu['fid']==0)
                                      <td style="vertical-align: middle !important;" class="text-left inner" rowspan="{{ $menu->count+1 }}">{{ $menu->name }}</td>
                                      @endif
                                      <td>{{ $menu['name'] }}</td>
                                      <!-- <td>{{ $menu['fname'] }}</td> -->
                                      <td>{{ $menu['type'] }}</td>
                                      <td>{{ $menu['key'] }}</td>
                                      <td>{{ $menu['url'] }}</td>
                                      <td>{{ $menu['sort'] }}</td>
                                      <td>
                                          
                                          <a href="{{ route('admin.wechat.menu.edit',['id'=>$menu->id]) }}"
                                                   class="btn btn-white btn-xs"><i class="icon-pencil"></i> 编辑</a>
                                                <a class="btn btn-danger btn-xs menu-delete"
                                                   data-href="{{ route('admin.wechat.menu.destroy',['id'=>$menu->id]) }}">
                                                    <i class="icon-trash"></i> 删除</a>

                                      </td>
                                  </tr>
                                  
                              @endforeach
                              <!-- <tr>
                                  <td style="vertical-align: middle !important;" class="text-center inner" rowspan="2">第一级菜单</td>
                                  <td>第一级菜单</td>
                                  <td></td>
                                  <td>链接</td>
                                  <td></td>
                                  <td>www.baidu.com</td>
                                  <td>
                                      
                                      <a href=""
                                               class="btn btn-white btn-xs"><i class="icon-pencil"></i> 编辑</a>
                                            <a class="btn btn-danger btn-xs user-delete"
                                               data-href="">
                                                <i class="icon-trash"></i> 删除</a>

                                  </td>
                              </tr>
                              <tr>

                                  <td>第一级子菜单（1）</td>
                                  <td>第一级菜单</td>
                                  <td>链接</td>
                                  <td></td>
                                  <td>1.com</td>
                                   <td>
                                       <a href=""
                                               class="btn btn-white btn-xs"><i class="icon-pencil"></i> 编辑</a>
                                            <a class="btn btn-danger btn-xs user-delete"
                                               data-href="">
                                                <i class="icon-trash"></i> 删除</a>   
                                   </td>
                              </tr> -->
                              <tr></tr>
                              </tbody>
                          </table>
                      </section>
                  </div>

              </div>
                         
                        
                    </div><!-- panel-body -->
                </div><!-- panel -->

              </section>
          </div>
      </div>
      <!-- page end-->
  </section>
</section>
@endsection

@section('javascript')
    @parent
    <!-- <script src="{{ asset('js/ajax.js') }}"></script> -->
    <script>
        

        $(".menu-delete").click(function () {
            Rbac.ajax.delete({
                type:'get',
                confirmTitle: '确定删除该菜单吗？',
                href: $(this).data('href'),
                successTitle: '菜单删除成功'
            });
        });

        $(".deleteall").click(function () {
            Rbac.ajax.deleteAll({
                confirmTitle: '确定删除选中的菜单吗？',
                href: $(this).data('href'),
                successTitle: '菜单删除成功'
            });
        });
    </script>

@endsection
